package cn.fu.customTag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;

/**
 * @Title: BodyTagSupertTag.java
 * @Package cn.fu.customTag
 * @Description: TODO(用一句话描述该文件做什么)
 * @author zhangxiaofu
 * @Company www.viewhigh.com
 * @date 2016年7月23日 下午10:27:43
 * @version V1.0
 */
public class BodyTagSupportDemo extends BodyTagSupport {
	private BodyContent bodyContent;

	@Override
	public void setBodyContent(BodyContent b) {
		this.bodyContent = b;
	}
	
	@Override
	public int doEndTag() throws JspException {
		//得到标签体内容
		String content = bodyContent.getString();
		System.err.println(content);
		
		String newStr = "改变后的标签体";
		//得到写出流
		JspWriter jspWriter = bodyContent.getEnclosingWriter();
		try {
			jspWriter.write(newStr);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_PAGE;
	}
}
